﻿@using Orchard.ContentManagement

@{
    ContentItem item = (ContentItem)Model.ContentPart.ContentItem;
   
    var permalink = (new Uri(HttpContext.Current.Request.Url, Url.ItemDisplayUrl(item))).ToString();
    var uniqueId = Model.DisqusUniqueId;
    var shortName = Model.DisqusSettings.ShortName;

    Style.Require("DisqusModule");
}

@if (HttpContext.Current.Request.Browser.Crawler)
{
    @Display(Model.Metadata.ChildContent)
}
else
{
    <div class="disqus-wrapper">
        <div id="disqus_thread"></div>
        <script type="text/javascript">
            var disqus_shortname = '@shortName'; 
            var disqus_developer = 1;

            var disqus_url = '@permalink';
            var disqus_identifier = '@uniqueId';
    
            (function () {
                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
            })();
        </script>
        <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
        <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
    </div>
}